home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / net / parnet-3.2 / extras / parpc / pcfiles / talk.c < prev    next >
C/C++ Source or Header  |  1995-03-09  |  1KB  |  65 lines

  1. /* TALK.C: To test sending from PC to amiga
  2.  * 1. on your amiga, type: machaddr 4
  3.  *                         listen 4
  4.  * 2. on the PC, type:     talk
  5.  */
  6. #include <stdio.h>
  7. #include <signal.h>
  8. #include "pardev.h"
  9.  
  10. typedef struct {
  11. int length;
  12. unsigned char buffer[255];
  13. } Data;
  14.  
  15. Data Dat[2];
  16.  
  17. int Trigger=0;
  18.  
  19. void ParAbort(void)
  20. {
  21.   par_stop();
  22.   printf("Aborted.\n");
  23.   exit(1);
  24. }
  25.  
  26. void parint(void)
  27. {
  28.  unsigned char buffer[255];
  29.  int Length;
  30.  
  31.  printf("i\n");
  32.  if (ParDataReady())
  33.  {
  34.    Length=ParRead(buffer,255);
  35.    if (Length > 0)
  36.    {
  37.      memcpy(Dat[Trigger].buffer,buffer,Length);
  38.      Dat[Trigger].length=Length;
  39.      Trigger+=1;
  40.    }
  41.  }
  42. }
  43.  
  44. main(int argc,char **argv)
  45. {
  46.  int Ready;
  47.  char buffer[255]="0000000012345678\0\0"; /* just something to fill it */
  48.  
  49.  par_init(1,0x0278);
  50. /* signal(SIGINT,ParAbort);
  51.    signal(SIGABRT,ParAbort);
  52. */
  53.  ctrlbrk(ParAbort);
  54.  
  55.  buffer[0]=0;
  56.  buffer[1]=4;    /* port = 4 */
  57.  buffer[2]=0;
  58.  buffer[3]=0;    /* checksum = 0 */
  59.  buffer[4]=0;
  60.  buffer[5]=0;
  61.  buffer[6]=0;
  62.  buffer[7]=8;    /* length = 8 */
  63.  parwrite(4,buffer,16); /* just a 'single shot' test */
  64. }
  65.